@layout("/common/_curd/_container.html"){

<script type="text/javascript">
	var ctx = "${basePath}";
	var grid_selector = "#grid-table";
	var pager_selector = "#grid-pager";
	
	$(function(){
		initGrid();
		initMenuBtn("btns", "${code}");
	});
	
	function initGrid(){
		var grid_url = ctx + "/${code}/list";
		var _colnames = ["", 
						"产品", 
						"开数",
						"起价",
						"起价数量",
						"续价"
		];
		var _colmodel = [{name:"id", index:"id", hidden:true,width:100},
						{name:"pname", index:"pname", width:100},
						{name:"name", index:"name", width:100},
						{name:"f_prise", index:"f_prise", width:100},
						{name:"f_num", index:"f_num", width:100},
						{name:"l_prise", index:"l_prise", width:100}
		];
		
		jQuery(grid_selector).jqGrid({
			url : grid_url,
		    shrinkToFit : true,
			colNames : _colnames,
			colModel : _colmodel, 
			jsonReader : {id :"id"},
			pager : pager_selector,
			postData : {sort : "id",
                where:"{p_id:'${pid!}'}",
				order : "desc"}
		});
	}
</script>

<input type="hidden" id="pid" value="${pid!}">

	<!-- 配置 grid -->
	<div class="row">
		<div class="col-xs-12 tb-grid">
			<!--<div class="welljq well-sm" id="btns"></div>-->
			<div>
				<button type="button" class="btn btn-white" onclick="add()">新增</button>
				<button type="button" class="btn btn-white" onclick="edit()">修改</button>
				<button type="button" class="btn btn-white" onclick="remove()">删除</button>
			</div>
			<!-- grid -->
			<table id="grid-table"></table>
			<!-- 分页-->
			<div id="grid-pager"></div>
		</div>
	</div>
	
	<!-- 引入所需的js -->
	@include("/common/_listscript.html"){}

<script>
	add = function () {
        var index = layer.open({
            type: 2,
            title:'查看详情',
            area: ['90%', '70%'],
            maxmin:true,
            shadeClose: true, //点击遮罩关闭
            content:  '/producttech/add2'
        });

        this.layerIndex = index;
    }

    edit = function () {

        var ids = $("#grid-table").jqGrid("getGridParam", "selarrrow");
        console.log(ids)
        // if(ids.size() >1){
	     //    layer.msg("请不要选择多项！")
		// 	return false;
		// }else if(ids.size() < 1){
         //    layer.msg("请选择一项进行操作！")
         //    return false;
		// }

        var index = layer.open({
            type: 2,
            title:'查看详情',
            area: ['90%', '70%'],
            maxmin:true,
            shadeClose: true, //点击遮罩关闭
            content:  '/producttech/edit2/'+ids
        });

        this.layerIndex = index;
    }

    remove = function () {

        var ids = $("#grid-table").jqGrid("getGridParam", "selarrrow");

        var ajaxURL = "/producttech/remove?ids="+ ids;
        $.post(ajaxURL,null,function (res) {
            if(res["success"]){
                layer.msg("操作成功！", {shift: -1,time:800,end:function () {
                        window.location.href="/product/";
                    }});
            }
        });

    }
</script>

@}	